//用户账号管理相关的接口函数
import request from '@/utils/request'
//登录
export const loginAPI = data => {
    // console.log("登录的账号",data)
    return request({
        url: `/login/${data.verifyCode}`,
        method: 'POST',
        data
    })
}
//登出
export const logoutAPI = () => {
    return request({
        url: `/logout`,
        method: 'POST'
    })
}
//手机号注册
export const registerByTelephoneApi = data => {
    return request({
        url: `/reginster/telephone/${data.verifyCode}`,
        method: 'POST',
        data:{
            telephone:data.telephone,
            email:data.email,
            password:data.password,
            authority:data.authority
        }
    })
}

//邮箱注册
export const registerByEmailApi = data => {
    return request({
        url: `/reginster/email/${data.verifyCode}`,
        method: 'POST',
        data:{
            telephone:data.telephone,
            email:data.email,
            password:data.password,
            authority:data.authority
        }
    })
}

//token获取用户账号信息
export const getAccountApi = () => {
    return request({
        url: `/user`,
        method:"get"
    })
}

//id获取用户账号信息
export const getAccountByIdApi = id => {
    return request({
        url: `/user/${id}`,
        method:"get"
    })
}

//上传用户头像
export const uploadAccountAvatarApi = file => {
    return request.putForm(`/user/avatar`, {file})
}
//更改用户邮箱
export const updateAccountEmailApi = (pw,newEmail) => {
    return request.putForm(`/user/upEmail`, {pw,newEmail})
}
//更改用户手机号
export const updateAccountTelephoneApi = (pw,newTelephone) => {
    return request.putForm(`/user/upTelephone`, {pw,newTelephone})
}
//更改用户密码
export const updateAccountPasswordApi = (oldPw,newPw) => {
    return request.putForm(`/user/upPw`, {oldPw,newPw})
}

